package com.google.code.swingonfire.component.button;

import java.util.ArrayList;
import java.util.List;

import javax.swing.AbstractListModel;
import javax.swing.Action;

public class MultiButtonListModel extends AbstractListModel
{

    private static final long serialVersionUID = 7986355919192163445L;

    private final List<Action> actions;

    public MultiButtonListModel()
    {
        this(new ArrayList<Action>());
    }

    public MultiButtonListModel(List<Action> actions)
    {
        super();

        this.actions = actions;
    }

    @Override
    public int getSize()
    {
        return actions.size();
    }

    public void addElement(Action action)
    {
        actions.add(action);

        fireIntervalAdded(this, actions.size() - 1, actions.size() - 1);
    }

    @Override
    public Object getElementAt(int index)
    {
        return actions.get(index);
    }

}
